import pandas as pd

path = "rawdata2020122602.csv"
df = pd.read_csv(path)

df_normal = df[df["label"] == 1]  # 正常脚本数据

df_webshell = df[df["label"] == 0]  # webshell脚本数据

normal_static = []
webshell_static = []

def static(data):
    res = []
    for index, row in data.iterrows():
        row_data = row["data"]
        res.append(len(row_data.split()))
    res.sort()
    return res

all = static(df)



normal_static = static(df_normal)
print(len(normal_static))
webshell_static = static(df_webshell)


distance = [1, 50, 100, 200, 400, 600, 800, 1000, 2000]
resnormal = pd.cut(normal_static, distance, right=True)

print(resnormal.value_counts())


print(len(webshell_static))
reswebshell = pd.cut(webshell_static, distance, right=True)

print(reswebshell.value_counts())


print(len(all))
resall = pd.cut(all, distance, right=True)
print(resall.value_counts())